package com.toy.abash.web;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.toy.abash.domain.Reply;
import com.toy.abash.service.ReplyManager;
import com.toy.core.web.BaseController;

@Controller
@RequestMapping("/abash/reply")
public class ReplyController extends BaseController {
	
	@Autowired
	private ReplyManager replyManager;
	
	@RequestMapping("/save")
	public String saveReply(Reply reply,@RequestParam long postId,HttpServletRequest request){
		reply.setAbashId(postId);
		reply.setIpaddress(request.getRemoteAddr());
		reply.setReplyDate(new Date());  
		reply.setState(Reply.STATE_NORMAL);
		replyManager.saveReply(reply);
		return "redirect:/abash/post/view/"+postId;
	}
}
